package com.sciencep.pro.admin.system.common.web;

import com.sciencep.pro.common.filter.SpaceFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.servlet.DispatcherType;
import javax.servlet.Filter;


@Configuration
public class WebMvcConfiguration implements WebMvcConfigurer {

    @Bean
    public FilterRegistrationBean<Filter> spaceFilter() {
        FilterRegistrationBean<Filter> filter = new FilterRegistrationBean<>();
        filter.setFilter(new SpaceFilter());
        filter.addUrlPatterns("/*");

        filter.setName("SpaceFilter");
        filter.setDispatcherTypes(DispatcherType.REQUEST);
        return filter;
    }
}
